import googleModal from '@/components/google-modal.vue'

export default {
	install(Vue, options) {
		const {
			store
		} = options; // 从 options 中获取 store
		const Profile = Vue.extend(googleModal)
		// 打开谷歌验证弹窗
		Vue.prototype.$openGoogleModal = function(callbackfun) {
			const instance = new Profile({
				store // 将 store 传递给实例
			})
			instance.googleModalShow = true;
			instance._props.callbackfun = callbackfun
			instance.vm = instance.$mount()
			const InviteEle = document.body.lastElementChild
			if (InviteEle.className === 'googleModal') return
			setTimeout(() => document.body.appendChild(instance.vm.$el))
			return instance
		}
		// 关闭谷歌验证弹窗
		Vue.prototype.$closeGoogleModal = function() {
			const instance = new Profile({
				store // 将 store 传递给实例
			})
			instance.googleModalShow = false;
			instance.vm = instance.$mount()
			const InviteEle = document.body.lastElementChild
			if (InviteEle.className !== 'googleModal') return
			document.body.removeChild(InviteEle)
			return instance
		}
	}
}